import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_billi/util/format_util.dart';
import 'package:flutter_billi/widget/NavigationBar.dart';
import 'package:flutter_statusbar_manager/flutter_statusbar_manager.dart';

Widget cachedImage(String url, {double width, double height}) {
  return CachedNetworkImage(
    imageUrl: url,
    width: width,
    height: height,
    fit: BoxFit.cover,
    placeholder: (BuildContext context, String url) => Container(
      color: Colors.grey[200],
    ),
    errorWidget: (BuildContext context, String url, dynamic error) => Icon(Icons.error),
  );
}

// 黑色 线性渐变

blackLinearGradient({bool fromTop = false}) {
  return LinearGradient(
      begin: fromTop ? Alignment.topCenter : Alignment.bottomCenter,
      end: fromTop ? Alignment.bottomCenter : Alignment.topCenter,
      colors: [
        Colors.black54,
        Colors.black45,
        Colors.black38,
        Colors.black26,
        Colors.black12,
        Colors.transparent,
      ]);
}

// 修改状态栏
void changeStatusBar({color: Colors.white, StatusStyle statusStyle: StatusStyle.LIGHT_CONTENT}) {
  FlutterStatusbarManager.setColor(color, animated: false);
  FlutterStatusbarManager.setStyle(
      statusStyle == StatusStyle.DARK_CONTENT ? StatusBarStyle.DARK_CONTENT : StatusBarStyle.LIGHT_CONTENT);
}

// 实现 带文字的小图标

smallIconText(IconData iconData, var text) {
  var style = TextStyle(fontSize: 12, color: Colors.grey);
  if (text is int) {
    text = countFormat(text);
  }
  return [
    Icon(
      iconData,
      color: Colors.grey,
      size: 16,
    ),
    Text(
      '${text}',
      style: style,
    )
  ];
}

/// borderLine 设置
borderLine(BuildContext context, {bottom: true, top: false}) {
  BorderSide borderside = BorderSide(width: 0.5, color: Colors.grey[200]);
  return Border(bottom: bottom ? borderside : BorderSide.none, top: top ? borderside : BorderSide.none);
}

SizedBox hiSpace({double width: 1, double height: 3}) {
  return SizedBox(
    height: height,
    width: width,
  );
}
// 修改底部阴影

///底部阴影
// BoxDecoration bottomBoxShadow() {
//   return BoxDecoration(color: Colors.white, boxShadow: [
//     BoxShadow(
//         color: Colors.grey[100],
//         offset: Offset(0, 5), //xy轴偏移
//         blurRadius: 5.0, //阴影模糊程度
//         spreadRadius: 1 //阴影扩散程度
//         )
//   ]);
// }

BoxDecoration bottomBoxShadow() {
  return BoxDecoration(
    color: Colors.white,
    boxShadow: [
      BoxShadow(
        color: Colors.grey[100],
        offset: Offset(0, 5),
        blurRadius: 5,
        spreadRadius: 1,
      )
    ],
  );
}
